package com.qianyu.project.web.controller.nyx;

import com.qianyu.project.entity.DesignModify;
import com.qianyu.project.entity.TechnicalDisclosure;
import com.qianyu.project.service.IDesignModifyService;
import com.qianyu.project.service.ITechnicalDisclosureService;
import com.qianyu.project.utils.Result;
import com.qianyu.project.utils.ResultTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

@RestController
@RequestMapping("NyxTechnicalDisclosure")
public class NyxTechnicalDisclosureController {

    @Autowired
    private ITechnicalDisclosureService technicalDisclosureService;

    @GetMapping("")
    public Result getList(@RequestParam Map<String, String> map){
        return ResultTool.success(technicalDisclosureService.getList(map));
    }

    @DeleteMapping("/{id}")
    public Result del(@PathVariable String id){
        technicalDisclosureService.removeByIds(Arrays.asList(id.split(",").clone()));
        return ResultTool.success();
    }

    @GetMapping("/id")
    public Result getId(){
        return ResultTool.success(technicalDisclosureService.getId());
    }

    @PostMapping("")
    public Result save(@RequestBody TechnicalDisclosure technicalDisclosure){
        technicalDisclosureService.add(technicalDisclosure);
        return  ResultTool.success();
    }

    @PutMapping("")
    public Result update(@RequestBody TechnicalDisclosure technicalDisclosure){
        System.out.println(technicalDisclosure);
        technicalDisclosureService.updateTech(technicalDisclosure);
        return  ResultTool.success();
    }
}
